﻿using Avalonia.Data.Converters;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Avalonia.Data;
using Avalonia.Data.Converters;
using Avalonia.Markup.Xaml;

namespace AvaloniaApplication.Converts
{
    public class TestConvert : MarkupExtension, IValueConverter
    {
        public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
        {
            if (value == null)
            {
                return string.Empty;
            }

            double dd = 0;
            if (double.TryParse(value.ToString(), out dd))
            {
                if (dd > 99)
                {
                    return "aaaaa";
                }

                return dd.ToString();
            }
            else
            {
                return string.Empty;
            }
            

        }

        public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            return new TestConvert();
        }
    }
}
